int ENA_1 = 2;
int DIR_1 = 3;
int PUL_1 = 4;

void setup() {
  // put your setup code here, to run once:
  pinMode(ENA_1, OUTPUT);
  pinMode(DIR_1, OUTPUT);
  pinMode(PUL_1, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  turn(1, 2000, 0, 1200); 
  delay(500);
  turn(1, 2000, 1, 1200);
  delay(500); 

  // 开启电机
  //digitalWrite(ENA_1, LOW);
  // 关闭电机
  //digitalWrite(ENA_1, HIGH);
}

void turn(int motor_no, int count, int dir, int speed) {

  if (motor_no == 1) {
    digitalWrite(DIR_1, dir);

    for (int i = 0; i < count; i++) {
      digitalWrite(PUL_1, HIGH);
      delayMicroseconds(speed);
      digitalWrite(PUL_1, LOW);
      delayMicroseconds(speed);
    }
  }

  //  if (motor_no == 2) {
  //    digitalWrite(DIR_2, dir);
  //
  //    for (int i = 0; i < count; i++) {
  //      digitalWrite(PUL_2, HIGH);
  //      delayMicroseconds(speed);
  //      digitalWrite(PUL_2, LOW);
  //      delayMicroseconds(speed);
  //    }
  //  }
}